package com.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dao.TongJiDao;
import com.util.sqlSessionFactory;
@Controller
public class TongJiController {
	
	@RequestMapping(value="/TongJi.action",method=RequestMethod.POST)
	@ResponseBody
	public List<Map> TongJi(
			@CookieValue(value="user",defaultValue="")String userId,
            HttpServletResponse response,
			@RequestParam(value="date_time",defaultValue="")String date_time,
			@RequestParam(value="place",defaultValue="")String place,
			@RequestParam(value="money_in",defaultValue="")String  money_in,
            @RequestParam(value="money_out",defaultValue="")String money_out,
            @RequestParam(value="kind",defaultValue="")String kind,
            @RequestParam(value="remark",defaultValue="")String remark
            ){
		    SqlSession session =sqlSessionFactory.getSqlSession();
        	TongJiDao dao = session.getMapper(TongJiDao.class);
		    List<Map> result = dao.TongJi(userId, date_time, place, money_in, money_out, kind, remark);
		    System.out.println(result);
		    session.commit();
//		    System.out.println(result);
			return result;
     }
}
